package com.jt.common.util;

import java.util.HashMap;
import java.util.Map;

public class RegistryTest {
    private static Map<String,String> map = new HashMap<>();

    public static void domap(String service,String host){


            map.get(service);

    }

    public static String doLookup(String service){
        return map.get(service);
    }


    public static void main(String[] args) {
        String[] services = {"A","B","C","D"};
        String[] hosts={"192.168.1.1:8081","192.168.1.2:8082","192.168.1.3:8083","192.168.1.4:8084"};
        Thread t1 = new Thread(){
            @Override
            public void run() {
                for (int i = 0;i<services.length;i++){
                    domap(services[i],hosts[i]);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };

        Thread t2 = new Thread(){
            @Override
            public void run() {
                for (int i = 0;i<services.length;i++){
                    System.out.println(services[i]+":"+doLookup(services[i]));
                }
            }
        };

        t1.start();
        t2.start();

    }
}
